Skip to content

Code scanning: tooling, test helpers and the stack-trace and trust-name alerts - #49

Merged
agorischek merged 4 commits into
mainfrom
code-scanning-tooling
Nov 19, 2026
Merged

agorischek merged 4 commits into
mainfrom
code-scanning-tooling

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

Fixes the build, repository-tooling and test code scanning alerts open on main since the repository went public: #5, #6, #9, #11, #12, #14–#25 and #27. Alerts #13 and #26 are false positives, dismissed with reasons (below). The shipped-code ReDoS alerts are in #48.

Alert Where Fix
#5, #6 js/polynomial-redos packages/renderers/sdk/build/notices.mjs A module ID's query is cut at its first ? (indexOf), and an SPDX expression's first alternative is found word by word, instead of \?.*$ and \s+OR\s+.
#9, #12 js/incomplete-sanitization .github/projections/self-topology/releases.mjs tomlList, tools/cli/src/lib/release.ts table The key or table name is escaped whole ([\\^$.*+?()[\]{}|/-]). Before, a.b matched axb, a+b matched [aab], and a backslash was regex syntax.
#11 js/incomplete-sanitization tools/cli/src/lib/link.ts The POSIX launcher prints "the linked checkout is gone" with printf '%s: %s\n' and the message as a single-quoted word (the existing shellQuote), instead of escaping only backticks inside double quotes, where echo also read backslashes in the checkout path.
#14, #24 js/incomplete-multi-character-sanitization packages/integrations/vscode/scripts/docs.mjs heading anchors, tools/cli/src/lib/markdown.ts plain Tags are dropped in one scan (withoutTags) with the same result as <[^>]+>: no <…> is ever left, and a < that closes nothing stays text.
#15–#23 js/incomplete-multi-character-sanitization renderer unit tests (api, code-statistics, database, kit, runtime-policy, text-diff) One shared test helper, packages/renderers/kit/test/markup.mjs plain (a character scan, the one agentic-workflows' tests had), replaces the nine replace(/<[^>]+>/g, '') copies; agentic-workflows uses it too.
#25 js/stack-trace-exposure packages/renderers/testing/playwright/server.ts A failed relay answers with the error's message only; the String(error) fallback is a fixed message.
#27 rust/cleartext-logging packages/cli/tests/comparator_tests.rs The --trust run's result is named with_trust. CodeQL's sensitive-name heuristic classifies any name containing trusted (not untrusted) as secret data, so assert_eq!(…, "{trusted}") read as logging a secret.

Dismissed as false positives

  • Allow four dependency advisories that have no fix yet #13 js/incomplete-sanitization, tools/scripts/reference-docs/shared.mjs cell: the value is Markdown, not text. GitHub's tables give only \| a special meaning (in code spans too), so escaping each pipe is complete; escaping backslashes would double the cell's own Markdown, as in the `\S` patterns in docs/reference/schemas/definition.md. The function now says so.
  • Renderers: graph opening check, architecture one revision, boundary counts, database links #26 rust/cleartext-logging, packages/extractors/sdk/src/context.rs:195: the "sensitive" source is the extractor SDK's public, documented testing::trusted(…) (a test Context whose run trusts repository code), and the sink is Context::root's panic naming the extractor. Neither carries secret data; renaming a public SDK function to avoid a name heuristic isn't worth the break.

Tests

  • notices: a module ID with a query and \0 prefix, (MPL-2.0 OR Apache-2.0) electing MPL-2.0, and 100,000-character adversarial inputs bounded at 1 s.
  • table and tomlList find only the literal name.
  • The launcher, run with a checkout path holding `, $HOME, ", \n and ', exits 3 and prints the path as it is.
  • withoutTags and heading anchors: tags dropped, <<script>script> leaves no tag, a lone < kept, linear on 100,000 < (the old regex took 3.4 s).

Verified with tools check --fast (cargo check included) and the unit suites of renderer kit, agentic-workflows, api, code-statistics, database, runtime-policy, text-diff, renderer-testing and the VS Code integration, plus tools/cli's markdown, link and release tests and the self-topology tests.

…me alerts

Fixes the build, repository-tooling and test alerts code scanning has had
open on main since the repository went public.

- Renderer notices (alerts 5, 6): a module ID's query is cut at its first `?`
  and an SPDX expression's first alternative found word by word, instead of
  `\?.*$` and `\s+OR\s+`, which went quadratic on long runs.
- Regular expressions built from names (alerts 9, 12): the TOML key and table
  name are escaped whole; `.`, `+` and a backslash used to match as syntax.
- The `projections-tools` launcher (alert 11) prints its "checkout is gone"
  message with printf and a single-quoted word, instead of escaping only
  backticks inside double quotes, where echo also read backslashes.
- Markdown to plain text (alerts 14, 24): tags are dropped in one scan with
  the same result as `<[^>]+>`.
- Renderer unit tests (alerts 15 to 23): one shared `plain` in
  renderers/kit/test/markup.mjs, a character scan, replaces nine copies of
  `replace(/<[^>]+>/g, '')` and agentic-workflows' own scan.
- The renderer test workbench (alert 25) answers a failed relay with the
  error's message only, never `String(error)`.
- comparator_tests (alert 27): the `--trust` run's result is `with_trust`;
  code scanning reads any name with `trusted` in it as secret data.
- reference-docs `cell` (alert 13) says why it escapes only pipes: GitHub's
  tables treat just `\|` specially and backslashes are the cell's Markdown.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the security hardening of build scripts, repository tooling, and test helpers.

No open issues 🎉

What changed in this PR

Addresses code-scanning alerts in Projections’ build scripts, repository tooling, and test helpers, complementing the shipped-code fixes in #48.

Changes:

  • Replaces vulnerable regex operations with linear scans or complete literal escaping, and safely quotes POSIX launcher diagnostics.
  • Consolidates renderer markup helpers, uses a fixed fallback for relay errors, and renames a test variable flagged by a sensitive-name heuristic.
  • Adds regression and adversarial-input tests, and documents the existing Markdown table-escaping behavior.
File Description
tools/​scripts/​reference-docs/​shared.mjs Adds a comment explaining Markdown table-cell escaping.
tools/​cli/​test/​release.test.ts Tests literal TOML table-name matching.
tools/​cli/​test/​markdown.test.ts Tests tag removal, edge cases, and large inputs.
tools/​cli/​test/​link.test.ts Tests launcher diagnostics with special characters in paths.
tools/​cli/​src/​lib/​release.ts Fully escapes table names used in regexes.
tools/​cli/​src/​lib/​markdown.ts Replaces regex tag removal with a linear scan.
tools/​cli/​src/​lib/​link.ts Uses quoted printf arguments for launcher errors.
packages/​renderers/​text-diff/​test/​view.test.mjs Uses the shared markup helper for status text.
packages/​renderers/​testing/​playwright/​server.ts Uses a fixed message for non-Error relay failures.
packages/​renderers/​sdk/​test/​notices.test.mjs Tests module queries, license alternatives, and large inputs.
packages/​renderers/​sdk/​build/​notices.mjs Reads module queries and license alternatives without vulnerable regexes.
packages/​renderers/​runtime-policy/​test/​runtime-policy.test.mjs Replaces local tag removal with the shared helper.
packages/​renderers/​kit/​test/​markup.mjs Adds the shared single-pass markup text helper.
packages/​renderers/​kit/​test/​group.test.mjs Uses the shared markup helper.
packages/​renderers/​kit/​test/​diff.test.mjs Uses the shared markup helper.
packages/​renderers/​database/​test/​types.test.mjs Uses the shared helper for rendered type text.
packages/​renderers/​code-statistics/​test/​diff.test.mjs Uses the shared helper after removing screen-reader-only spans.
packages/​renderers/​api/​test/​api.test.mjs Consolidates markup text extraction through the shared helper.
packages/​renderers/​agentic-workflows/​test/​agentic-workflows.test.mjs Moves its existing helper to the shared implementation.
packages/​integrations/​vscode/​test/​build.test.mjs Adds heading-anchor behavior and large-input tests.
packages/​integrations/​vscode/​scripts/​docs.mjs Scans HTML tags linearly when generating heading anchors.
packages/​cli/​tests/​comparator_tests.rs Renames the trust-result variable without changing assertions.
.github/​projections/​self-topology/​releases.test.mjs Tests literal TOML key matching.
.github/​projections/​self-topology/​releases.mjs Fully escapes TOML keys used in regexes.

Review effort: Balanced

@agorischek
agorischek merged commit e115b26 into main Nov 19, 2026
93 of 94 checks passed
@agorischek
agorischek deleted the code-scanning-tooling branch November 19, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants